{% extends "pages/body.html" %}
{% load i18n %}
{% load fbc %}
{% load pyif %}
{% block meta %}<link rel="stylesheet" href="/site_media/layout/forum.css" type="text/css" />{% endblock %}
{% block title %}{{ forum_name }} - {{ topic.name }}{% endblock %}
{% block header %}{{ forum_name }} - {{ topic.name }}{% endblock %}
{% block crumb %}<a href="/">{% trans "Home" %}</a> > <a href="/forum/">{% trans "Forum Index" %}</a> > <a href="/forum/forum/{{ forum_id }}/">{{ forum_name }}</a> > <a href="/forum/topic/1/{{ topic.id }}">{{ topic.name }}</a>{% endblock %}

{% block pagemenu %}
	{% if opened %}
		<li><a href="/forum/add_post/{{ topic.id }}/">{% trans "Add Post" %}</a></li>
	{% endif %}
	<li><a href="/forum/">{% trans "Back to Forum" %}</a></li>
	<li><a href="/forum/lasttopics/">{% trans "Last Active Topics" %}</a></li>
	<li><a href="/forum/mytopics/">{% trans "My Topics" %}</a></li>
	<li><a href="/forum/myptopics/">{% trans "My Posts" %}</a></li>
{% endblock %}

{% block content %}
<div id="feed">
{% for i in object_list %}
<dl>
	<dt>{% pyif user.get_profile.last_visit < i.date %}<a name="new"></a>{% endif %}<b>{% if i.author_anonymous %}~<i>{% endif %}{{ i.author}}{% if i.author_anonymous %}</i>{% endif %}</b><br />{{ i.date|date:"Y.m.d G:i" }}<br />{% if perms.is_staff %}{{ i.ip }}{% endif %}</dt>
	<dd>
	<ul>
		<li>
		{{ i.text|fbc|safe|urlizetrunc:"60" }}
		</li>
		<li class="post2">
			{% pyif perms.is_staff or is_author %}
				{% if topic.is_solved %}
					<a href="/forum/topic/unsolve/{{ topic.id }}/{{ forum_id }}/" class="unsolve">{% trans "Unsolve Topic" %}</a>
				{% else %}
					<a href="/forum/topic/solve/{{ topic.id }}/{{ forum_id }}/"  class="solve">{% trans "Mark as solved" %}</a>
				{% endif %}
			{% endif %}
			{% if perms.add_post %}
				{% if opened %}
					[<a href="/forum/add_post/{{ topic.id }}/{{ i.id }}/">{% trans "Reply with quote" %}</a>]
				{% endif %}
			{% endif %}
			{% ifequal i.author current_user %}
				{% if opened %}
					{% if not i.author_anonymous %}
						[<a href="/forum/edit_post/{{ i.id }}/">{% trans "Edit this post" %}</a>]
					{% endif %}
				{% endif %}
			{% else %}
				{% if perms.is_staff %}
					[<a href="/forum/edit_post/{{ i.id }}/">{% trans "Edit this post" %}</a>]
				{% endif %}
			{% endifequal %}
			{% if perms.is_staff %}
				[<a href="/forum/delete_post/{{ i.id }}/{{ topic.id }}/" onclick="return confirm('{% trans "Delete This Post?" %}')">{% trans "Delete this post" %}</a>]
			{% endif %}
		</li>
	</ul>
	</dd>
</dl>
{% endfor %}
</div>

{% ifnotequal pages 1 %}
<div class="box">
<strong>{% trans "Pages: " %}</strong>
{% for i in cnt %}
	[<a href="/forum/topic/{{ i }}/{{ topic.id }}/">{% ifequal i page %}<b>{{ i }}</b>{% else %}{{ i }}{% endifequal %}</a>]
{% endfor %}
</div>
{% endifnotequal %}

{% if perms.add_post %}
{% if opened %}
<form method="post" action="/forum/add_post/{{ topic.id }}/">
<div class="postform">
        <div class="posthead">{% trans "Add new post" %}</div>
	{% if not user.is_authenticated %}
		<div class="leftpostform">
			<strong>{% trans "Nick" %}</strong>
		</div>
		<div class="rightpostform">	
			{{ form.nick }}{% if form.nick.errors %}<br />*** {{ form.nick.errors|join:", " }}{% endif %}
		</div>
	{% endif %}
        <div class="leftpostform">
		<strong>{% trans "Content" %}</strong>
	</div>
	<div class="rightpostform">
		<a name="c"></a>
	      <textarea name="text" rows="6" cols="60">{{ text }}</textarea>
		<div><b>{% trans "Available Tags" %}</b>: [b], [u], [i], [code]. [python], [php], [url], [img], [quote].<br />
		{% trans "Use <b>[code] or [python], [php]</b> for code and config text pasting." %}</div>
	</div>
        <div class="leftpostform">
	</div>
	<div class="rightpostform">	
                <input type="submit" value="{% trans "Add post" %}" />
	</div>
    </div>
</form>
{% endif %}{% endif %}
{% if perms.is_spam %}
<div class="box">{% trans "To many anonymous posts. Login to post topics and new messages." %}</div>
{% endif %}

<p style="text-align:right;"><br />
	{% if perms.add_topic %}
		{% trans "You <b>can</b> post new Topics" %}<br />
	{% else %}
		{% trans "You <b>can't</b> post new Topics" %}<br />
	{% endif %}
	{% if perms.add_post %}
		{% trans "You <b>can</b> post new Posts" %}<br />
	{% else %}
		{% trans "You <b>can't</b> post new Posts" %}<br />
	{% endif %}
	{% if perms.is_staff %}
		{% trans "You <b>are</b> a Moderator" %}<br />
	{% else %}
		{% trans "You <b>aren't</b> a moderator" %}<br />
	{% endif %}
	</p>
{% endblock %}